# coding: utf8
# try something like
import os
cwd = os.getcwd()

def index(): return dict(message="hello from plugin_uc_janrain.py")

def display_static():
    """
    Displays app_name/plugin_name/static/
    """
    file_name=request.args(0) or redirect(URL('index'))    
    file_path = os.path.join(cwd,'applications',request.application, 'static', 'plugin_uc_janrain', file_name)
    if os.path.exists(file_path):
        content=open(file_path,'r').read()
        body = MARKMIN(content)
    else:
        body = MARKMIN('file not found %s' % file_path)
    return dict(body=body)

def user():
    rpx = ''
# following should be profile info but needs protable url 
    registerurl=URL('plugin_uc_janrain','user',args='register',vars=dict(_next='/init/default/somepage'))
    if request.vars.token:
        auth.settings.login_form = janrain_login_form
        return dict(form=auth())
    if 'login' in request.args:
        rpx = janrain_login_form.login_form()
        html = DIV(
               rpx,BR(),BR(),
               H2('Local login'),
               H3('use a username and password created for this site'),
               auth(),
              )
    else:
        html = auth()

    return dict(form=html)
